<!DOCTYPE html><html><head>
<title>pt::peg_language - Parser Tools</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.doctools_title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.doctools_section, LI.doctools_subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.doctools_example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.doctools_requirements LI, UL.doctools_syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.doctools_synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.doctools_syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.doctools_requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<!-- Generated from file 'pt_peg_language.man' by tcllib/doctools with format 'html'
   -->
<!-- Copyright &amp;copy; 2009 Andreas Kupries &amp;lt;andreas_kupries@users.sourceforge.net&amp;gt;
   -->
<!-- pt::peg_language.n
   -->
<body><hr> [
   <a href="../../../../../../../../home">Tcllib Home</a>
&#124; <a href="../../../../toc.html">Main Table Of Contents</a>
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">pt::peg_language(n) 1 tcllib &quot;Parser Tools&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>pt::peg_language - PEG Language Tutorial</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
<li class="doctools_section"><a href="#section1">Description</a></li>
<li class="doctools_section"><a href="#section2">What is it?</a></li>
<li class="doctools_section"><a href="#section3">The elements of the language</a>
<ul>
<li class="doctools_subsection"><a href="#subsection1">Basic structure</a></li>
<li class="doctools_subsection"><a href="#subsection2">Names</a></li>
<li class="doctools_subsection"><a href="#subsection3">Rules</a></li>
<li class="doctools_subsection"><a href="#subsection4">Expressions</a></li>
<li class="doctools_subsection"><a href="#subsection5">Whitespace and comments</a></li>
<li class="doctools_subsection"><a href="#subsection6">Nonterminal attributes</a></li>
</ul>
</li>
<li class="doctools_section"><a href="#section4">PEG Specification Language</a>
<ul>
<li class="doctools_subsection"><a href="#subsection7">Example</a></li>
</ul>
</li>
<li class="doctools_section"><a href="#section5">Bugs, Ideas, Feedback</a></li>
<li class="doctools_section"><a href="#keywords">Keywords</a></li>
<li class="doctools_section"><a href="#category">Category</a></li>
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">Tcl 8.5</b></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>
<p>Are you lost ?
Do you have trouble understanding this document ?
In that case please read the overview provided by the
<i class="term"><a href="pt_introduction.html">Introduction to Parser Tools</a></i>. This document is the
entrypoint to the whole system the current package is a part of.</p>
<p>Welcome to the tutorial / introduction for the
<span class="sectref"><a href="#section4">PEG Specification Language</a></span>.
If you are already familiar with the language we are about to discuss,
and only wish to refresh your memory you can, of course, skip ahead to
the aforementioned section and just read the full formal specification.</p>
</div>
<div id="section2" class="doctools_section"><h2><a name="section2">What is it?</a></h2>
<p><b class="const">peg</b>, a language for the specification of parsing expression
grammars is meant to be human readable, and writable as well, yet
strict enough to allow its processing by machine. Like any computer
language. It was defined to make writing the specification of a
grammar easy, something the other formats found in the Parser Tools do
not lend themselves too.</p>
</div>
<div id="section3" class="doctools_section"><h2><a name="section3">The elements of the language</a></h2>
<div id="subsection1" class="doctools_subsection"><h3><a name="subsection1">Basic structure</a></h3>
<p>The general outline of a textual PEG is</p>
<pre class="doctools_example">
PEG &lt;&lt;name&gt;&gt; (&lt;&lt;start-expression&gt;&gt;)
   &lt;&lt;rules&gt;&gt;
END;
</pre>
<p><em>Note</em>: We are using text in double angle-brackets as
place-holders for things not yet explained.</p>
</div>
<div id="subsection2" class="doctools_subsection"><h3><a name="subsection2">Names</a></h3>
<p>Names are mostly used to identify the nonterminal symbols of the
grammar, i.e. that which occurs on the left-hand side of a &lt;rule&gt;.
The exception to that is the name given after the keyword <b class="const">PEG</b>
(see previous section), which is the name of the whole grammar itself.</p>
<p>The structure of a name is simple:</p>
<ol class="doctools_enumerated">
<li><p>It begins with a letter, underscore, or colon, followed by</p></li>
<li><p>zero or more letters, digits, underscores, or colons.</p></li>
</ol>
<p>Or, in formal textual notation:</p>
<pre class="doctools_example">
    ([_:] / &lt;alpha&gt;) ([_:] / &lt;alnum&gt;)*
</pre>
<p>Examples of names:</p>
<pre class="doctools_example">
    Hello
    ::world
    _:submarine55_
</pre>
<p>Examples of text which are <em>not</em> names:</p>
<pre class="doctools_example">
    12
    .bogus
    0wrong
    @location
</pre>
</div>
<div id="subsection3" class="doctools_subsection"><h3><a name="subsection3">Rules</a></h3>
<p>The main body of the text of a grammar specification is taken up by
the rules. Each rule defines the sentence structure of one nonterminal
symbol. Their basic structure is</p>
<pre class="doctools_example">
     &lt;&lt;name&gt;&gt;  &lt;-  &lt;&lt;expression&gt;&gt; ;
</pre>
<p>The &lt;name&gt; specifies the nonterminal symbol to be defined, the
&lt;expression&gt; after the arrow (&lt;-) then declares its structure.</p>
<p>Note that each rule ends in a single semicolon, even the last.
I.e. the semicolon is a rule <em>terminator</em>, not a separator.</p>
<p>We can have as many rules as we like, as long as we define each
nonterminal symbol at most once, and have at least one rule for each
nonterminal symbol which occured in an expression, i.e. in either the
start expression of the grammar, or the right-hande side of a rule.</p>
</div>
<div id="subsection4" class="doctools_subsection"><h3><a name="subsection4">Expressions</a></h3>
<p>The <em>parsing</em> expressions are the meat of any specification. They
declare the structure of the whole document (&lt;&lt;start-expression&gt;&gt;),
and of all nonterminal symbols.</p>
<p>All expressions are made up out of <i class="term">atomic expressions</i> and
<i class="term">operators</i> combining them. We have operators for choosing
between alternatives, repetition of parts, and for look-ahead
constraints. There is no explicit operator for the sequencing (also
known as <i class="term">concatenation</i>) of parts however. This is specified by
simply placing the parts adjacent to each other.</p>
<p>Here are the operators, from highest to lowest priority (i.e. strength
of binding):</p>
<pre class="doctools_example">
    # Binary operators.
    &lt;&lt;expression-1&gt;&gt;     &lt;&lt;expression-2&gt;&gt;  # sequence. parse 1, then 2.
    &lt;&lt;expression-1&gt;&gt;  /  &lt;&lt;expression-2&gt;&gt;  # alternative. try to parse 1, and parse 2 if 1 failed to parse.
    # Prefix operators. Lookahead constraints. Same priority.
    &amp; &lt;&lt;expression&gt;&gt;  # Parse expression, ok on successful parse.
    ! &lt;&lt;expression&gt;&gt;  # Ditto, except ok on failure to parse.
    # Suffix operators. Repetition. Same priority.
    &lt;&lt;expression&gt;&gt; ?  # Parse expression none, or once (repeat 0 or 1).
    &lt;&lt;expression&gt;&gt; *  # Parse expression zero or more times.
    &lt;&lt;expression&gt;&gt; +  # Parse expression one or more times.
    # Expression nesting
    ( &lt;&lt;expression&gt;&gt; ) # Put an expression in parens to change its priority.
</pre>
<p>With this we can now deconstruct the formal expression for names given
in section <span class="sectref"><a href="#subsection2">Names</a></span>:</p>
<pre class="doctools_example">
    ([_:] / &lt;alpha&gt;) ([_:] / &lt;alnum&gt;)*
</pre>
<p>It is a sequence of two parts,</p>
<pre class="doctools_example">    [_:] / &lt;alpha&gt; </pre>
<p>and</p>
<pre class="doctools_example">    ([_:] / &lt;alnum&gt;)* </pre>
<p>The parentheses around the parts kept their inner alternatives bound
together against the normally higher priority of the sequence. Each of
the two parts is an alternative, with the second part additionally
repeated zero or more times, leaving us with the three atomic
expressions</p>
<pre class="doctools_example">
    [_:]
    &lt;alpha&gt;
    &lt;alnum&gt;
</pre>
<p>And <i class="term">atomic expressions</i> are our next topic. They
fall into three classes:</p>
<ol class="doctools_enumerated">
<li><p>names, i.e. nonterminal symbols,</p></li>
<li><p>string literals, and</p></li>
<li><p>character classes.</p></li>
</ol>
<p>Names we know about already, or see section <span class="sectref"><a href="#subsection2">Names</a></span> for a
refresher.</p>
<p>String literals are simple. They are delimited by (i.e. start and end
with) either a single or double-apostroph, and in between the
delimiters we can have any character but the delimiter itself. They
can be empty as well. Examples of strings are</p>
<pre class="doctools_example">
    ''
    &quot;&quot;
    'hello'
    &quot;umbra&quot;
    &quot;'&quot;
    '&quot;'
</pre>
<p>The last two examples show how to place any of the delimiters into a
string.</p>
<p>For the last, but not least of our atomic expressions, character
classes, we have a number of predefined classes, shown below, and the
ability to construct or own. The predefined classes are:</p>
<pre class="doctools_example">
    &lt;alnum&gt;    # Any unicode alphabet or digit character (string is alnum).
    &lt;alpha&gt;    # Any unicode alphabet character (string is alpha).
    &lt;ascii&gt;    # Any unicode character below codepoint 0x80 (string is ascii).
    &lt;control&gt;  # Any unicode control character (string is control).
    &lt;ddigit&gt;   # The digit characters [0-9].
    &lt;digit&gt;    # Any unicode digit character (string is digit).
    &lt;graph&gt;    # Any unicode printing character, except space (string is graph).
    &lt;lower&gt;    # Any unicode lower-case alphabet character (string is lower).
    &lt;print&gt;    # Any unicode printing character, incl. space (string is print).
    &lt;punct&gt;    # Any unicode punctuation character (string is punct).
    &lt;space&gt;    # Any unicode space character (string is space).
    &lt;upper&gt;    # Any unicode upper-case alphabet character (string is upper).
    &lt;wordchar&gt; # Any unicode word character (string is wordchar).
    &lt;xdigit&gt;   # The hexadecimal digit characters [0-9a-fA-F].
    .          # Any character, except end of input.
</pre>
<p>And the syntax of custom-defined character classes is</p>
<pre class="doctools_example">
    [ &lt;&lt;range&gt;&gt;* ]
</pre>
<p>where each range is either a single character, or of the form</p>
<pre class="doctools_example">
   &lt;&lt;character&gt;&gt; - &lt;character&gt;&gt;
</pre>
<p>Examples for character classes we have seen already in the course of
this introduction are</p>
<pre class="doctools_example">
    [_:]
    [0-9]
    [0-9a-fA-F]
</pre>
<p>We are nearly done with expressions. The only piece left is to tell
how the characters in character classes and string literals are
specified.</p>
<p>Basically characters in the input stand for themselves, and in
addition to that we several types of escape syntax to to repesent
control characters, or characters outside of the encoding the text is
in.</p>
<p>All the escaped forms are started with a backslash character ('\',
unicode codepoint 0x5C). This is then followed by a series of octal
digits, or 'u' and hexedecimal digits, or a regular character from a
fixed set for various control characters. Some examples:</p>
<pre class="doctools_example">
    \n \r \t \' \&quot; \[ \] \\ #
    \000 up to \277         # octal escape, all ascii character, leading 0's can be removed.
    \u2CA7                  # hexadecimal escape, all unicode characters.
    #                       # Here 2ca7 &lt;=&gt; Koptic Small Letter Tau
</pre>
</div>
<div id="subsection5" class="doctools_subsection"><h3><a name="subsection5">Whitespace and comments</a></h3>
<p>One issue not touched upon so far is whitespace and comments.</p>
<p>Whitespace is any unicode space character, i.e. anything in the
character class &lt;space&gt;, and comments. The latter are sequences of
characters starting with a '#' (hash, unicode codepoint 0x23) and
ending at the next end-of-line.</p>
<p>Whitespace can be freely used between all syntactical elements of a
grammar specification. It cannot be used inside of syntactical
elements, like names, string literals, predefined character classes,
etc.</p>
</div>
<div id="subsection6" class="doctools_subsection"><h3><a name="subsection6">Nonterminal attributes</a></h3>
<p>Lastly, a more advanced topic. In the section <span class="sectref"><a href="#subsection3">Rules</a></span> we gave
the structure of a rule as</p>
<pre class="doctools_example">
     &lt;&lt;name&gt;&gt;  &lt;-  &lt;&lt;expression&gt;&gt; ;
</pre>
<p>This is not quite true. It is possible to associate a semantic mode
with the nonterminal in the rule, by writing it before the name,
separated from it by a colon, i.e. writing</p>
<pre class="doctools_example">
    &lt;&lt;mode&gt;&gt; : &lt;&lt;name&gt;&gt;  &lt;-  &lt;&lt;expression&gt;&gt; ;
</pre>
<p>is also allowed. This mode is optional. The known modes and their
meanings are:</p>
<dl class="doctools_definitions">
<dt><b class="const">value</b></dt>
<dd><p>The semantic value of the nonterminal symbol is an abstract syntax
tree consisting of a single node node for the nonterminal itself,
which has the ASTs of the symbol's right hand side as its children.</p></dd>
<dt><b class="const">leaf</b></dt>
<dd><p>The semantic value of the nonterminal symbol is an abstract syntax
tree consisting of a single node node for the nonterminal, without any
children. Any ASTs generated by the symbol's right hand side are
discarded.</p></dd>
<dt><b class="const">void</b></dt>
<dd><p>The nonterminal has no semantic value. Any ASTs generated by the
symbol's right hand side are discarded (as well).</p></dd>
</dl>
<p>Of these three modes only <b class="const">leaf</b> and <b class="const">void</b> can be
specified directly. <b class="const">value</b> is implicitly specified by the
absence of a mode before the nonterminal.</p>
<p>Now, with all the above under our belt it should be possible to not
only read, but understand the formal specification of the text
representation shown in the next section, written in itself.</p>
</div>
</div>
<div id="section4" class="doctools_section"><h2><a name="section4">PEG Specification Language</a></h2>
<p><b class="const">peg</b>, a language for the specification of parsing expression
grammars is meant to be human readable, and writable as well, yet
strict enough to allow its processing by machine. Like any computer
language. It was defined to make writing the specification of a
grammar easy, something the other formats found in the Parser Tools do
not lend themselves too.</p>
<p>It is formally specified by the grammar shown below, written in
itself. For a tutorial / introduction to the language please go and
read the <i class="term">PEG Language Tutorial</i>.</p>
<pre class="doctools_example">
PEG pe-grammar-for-peg (Grammar)
	# --------------------------------------------------------------------
        # Syntactical constructs
        Grammar         &lt;- WHITESPACE Header Definition* Final EOF ;
        Header          &lt;- PEG Identifier StartExpr ;
        Definition      &lt;- Attribute? Identifier IS Expression SEMICOLON ;
        Attribute       &lt;- (VOID / LEAF) COLON ;
        Expression      &lt;- Sequence (SLASH Sequence)* ;
        Sequence        &lt;- Prefix+ ;
        Prefix          &lt;- (AND / NOT)? Suffix ;
        Suffix          &lt;- Primary (QUESTION / STAR / PLUS)? ;
        Primary         &lt;- ALNUM / ALPHA / ASCII / CONTROL / DDIGIT / DIGIT
                        /  GRAPH / LOWER / PRINTABLE / PUNCT / SPACE / UPPER
                        /  WORDCHAR / XDIGIT
                        / Identifier
                        /  OPEN Expression CLOSE
                        /  Literal
                        /  Class
                        /  DOT
                        ;
        Literal         &lt;- APOSTROPH  (!APOSTROPH  Char)* APOSTROPH  WHITESPACE
                        /  DAPOSTROPH (!DAPOSTROPH Char)* DAPOSTROPH WHITESPACE ;
        Class           &lt;- OPENB (!CLOSEB Range)* CLOSEB WHITESPACE ;
        Range           &lt;- Char TO Char / Char ;
        StartExpr       &lt;- OPEN Expression CLOSE ;
void:   Final           &lt;- &quot;END&quot; WHITESPACE SEMICOLON WHITESPACE ;
        # --------------------------------------------------------------------
        # Lexing constructs
        Identifier      &lt;- Ident WHITESPACE ;
leaf:   Ident           &lt;- ([_:] / &lt;alpha&gt;) ([_:] / &lt;alnum&gt;)* ;
        Char            &lt;- CharSpecial / CharOctalFull / CharOctalPart
                        /  CharUnicode / CharUnescaped
                        ;
leaf:   CharSpecial     &lt;- &quot;\\&quot; [nrt'&quot;\[\]\\] ;
leaf:   CharOctalFull   &lt;- &quot;\\&quot; [0-2][0-7][0-7] ;
leaf:   CharOctalPart   &lt;- &quot;\\&quot; [0-7][0-7]? ;
leaf:   CharUnicode     &lt;- &quot;\\&quot; 'u' HexDigit (HexDigit (HexDigit HexDigit?)?)? ;
leaf:   CharUnescaped   &lt;- !&quot;\\&quot; . ;
void:   HexDigit        &lt;- [0-9a-fA-F] ;
void:   TO              &lt;- '-'           ;
void:   OPENB           &lt;- &quot;[&quot;           ;
void:   CLOSEB          &lt;- &quot;]&quot;           ;
void:   APOSTROPH       &lt;- &quot;'&quot;           ;
void:   DAPOSTROPH      &lt;- '&quot;'           ;
void:   PEG             &lt;- &quot;PEG&quot; !([_:] / &lt;alnum&gt;) WHITESPACE ;
void:   IS              &lt;- &quot;&lt;-&quot;    WHITESPACE ;
leaf:   VOID            &lt;- &quot;void&quot;  WHITESPACE ; # Implies that definition has no semantic value.
leaf:   LEAF            &lt;- &quot;leaf&quot;  WHITESPACE ; # Implies that definition has no terminals.
void:   SEMICOLON       &lt;- &quot;;&quot;     WHITESPACE ;
void:   COLON           &lt;- &quot;:&quot;     WHITESPACE ;
void:   SLASH           &lt;- &quot;/&quot;     WHITESPACE ;
leaf:   AND             &lt;- &quot;&amp;&quot;     WHITESPACE ;
leaf:   NOT             &lt;- &quot;!&quot;     WHITESPACE ;
leaf:   QUESTION        &lt;- &quot;?&quot;     WHITESPACE ;
leaf:   STAR            &lt;- &quot;*&quot;     WHITESPACE ;
leaf:   PLUS            &lt;- &quot;+&quot;     WHITESPACE ;
void:   OPEN            &lt;- &quot;(&quot;     WHITESPACE ;
void:   CLOSE           &lt;- &quot;)&quot;     WHITESPACE ;
leaf:   DOT             &lt;- &quot;.&quot;     WHITESPACE ;
leaf:   ALNUM           &lt;- &quot;&lt;alnum&gt;&quot;    WHITESPACE ;
leaf:   ALPHA           &lt;- &quot;&lt;alpha&gt;&quot;    WHITESPACE ;
leaf:   ASCII           &lt;- &quot;&lt;ascii&gt;&quot;    WHITESPACE ;
leaf:   CONTROL         &lt;- &quot;&lt;control&gt;&quot;  WHITESPACE ;
leaf:   DDIGIT          &lt;- &quot;&lt;ddigit&gt;&quot;   WHITESPACE ;
leaf:   DIGIT           &lt;- &quot;&lt;digit&gt;&quot;    WHITESPACE ;
leaf:   GRAPH           &lt;- &quot;&lt;graph&gt;&quot;    WHITESPACE ;
leaf:   LOWER           &lt;- &quot;&lt;lower&gt;&quot;    WHITESPACE ;
leaf:   PRINTABLE       &lt;- &quot;&lt;print&gt;&quot;    WHITESPACE ;
leaf:   PUNCT           &lt;- &quot;&lt;punct&gt;&quot;    WHITESPACE ;
leaf:   SPACE           &lt;- &quot;&lt;space&gt;&quot;    WHITESPACE ;
leaf:   UPPER           &lt;- &quot;&lt;upper&gt;&quot;    WHITESPACE ;
leaf:   WORDCHAR        &lt;- &quot;&lt;wordchar&gt;&quot; WHITESPACE ;
leaf:   XDIGIT          &lt;- &quot;&lt;xdigit&gt;&quot;   WHITESPACE ;
void:   WHITESPACE      &lt;- (&quot; &quot; / &quot;\t&quot; / EOL / COMMENT)* ;
void:   COMMENT         &lt;- '#' (!EOL .)* EOL ;
void:   EOL             &lt;- &quot;\n\r&quot; / &quot;\n&quot; / &quot;\r&quot; ;
void:   EOF             &lt;- !. ;
        # --------------------------------------------------------------------
END;
</pre>
<div id="subsection7" class="doctools_subsection"><h3><a name="subsection7">Example</a></h3>
<p>Our example specifies the grammar for a basic 4-operation calculator.</p>
<pre class="doctools_example">
PEG calculator (Expression)
    Digit      &lt;- '0'/'1'/'2'/'3'/'4'/'5'/'6'/'7'/'8'/'9'       ;
    Sign       &lt;- '-' / '+'                                     ;
    Number     &lt;- Sign? Digit+                                  ;
    Expression &lt;- Term (AddOp Term)*                            ;
    MulOp      &lt;- '*' / '/'                                     ;
    Term       &lt;- Factor (MulOp Factor)*                        ;
    AddOp      &lt;- '+'/'-'                                       ;
    Factor     &lt;- '(' Expression ')' / Number                   ;
END;
</pre>
<p>Using higher-level features of the notation, i.e. the character
classes (predefined and custom), this example can be rewritten as</p>
<pre class="doctools_example">
PEG calculator (Expression)
    Sign       &lt;- [-+] 						;
    Number     &lt;- Sign? &lt;ddigit&gt;+				;
    Expression &lt;- '(' Expression ')' / (Factor (MulOp Factor)*)	;
    MulOp      &lt;- [*/]						;
    Factor     &lt;- Term (AddOp Term)*				;
    AddOp      &lt;- [-+]						;
    Term       &lt;- Number					;
END;
</pre>
</div>
</div>
<div id="section5" class="doctools_section"><h2><a name="section5">Bugs, Ideas, Feedback</a></h2>
<p>This document, and the package it describes, will undoubtedly contain
bugs and other problems.
Please report such in the category <em>pt</em> of the
<a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>.
Please also report any ideas for enhancements you may have for either
package and/or documentation.</p>
<p>When proposing code changes, please provide <em>unified diffs</em>,
i.e the output of <b class="const">diff -u</b>.</p>
<p>Note further that <em>attachments</em> are strongly preferred over
inlined patches. Attachments can be made by going to the <b class="const">Edit</b>
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar.</p>
</div>
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../../../index.html#ebnf">EBNF</a>, <a href="../../../../index.html#ll_k_">LL(k)</a>, <a href="../../../../index.html#peg">PEG</a>, <a href="../../../../index.html#tdpl">TDPL</a>, <a href="../../../../index.html#context_free_languages">context-free languages</a>, <a href="../../../../index.html#expression">expression</a>, <a href="../../../../index.html#grammar">grammar</a>, <a href="../../../../index.html#matching">matching</a>, <a href="../../../../index.html#parser">parser</a>, <a href="../../../../index.html#parsing_expression">parsing expression</a>, <a href="../../../../index.html#parsing_expression_grammar">parsing expression grammar</a>, <a href="../../../../index.html#push_down_automaton">push down automaton</a>, <a href="../../../../index.html#recursive_descent">recursive descent</a>, <a href="../../../../index.html#state">state</a>, <a href="../../../../index.html#top_down_parsing_languages">top-down parsing languages</a>, <a href="../../../../index.html#transducer">transducer</a></p>
</div>
<div id="category" class="doctools_section"><h2><a name="category">Category</a></h2>
<p>Parsing and Grammars</p>
</div>
<div id="copyright" class="doctools_section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2009 Andreas Kupries &lt;andreas_kupries@users.sourceforge.net&gt;</p>
</div>
</div></body></html>
